package com.jt.Demo03;
/**Spring入门-注解版*/
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class SpringAnno {
    public static void main(String[] args) {
        //利用注解启动spring容器
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringCatConfig.class);
        //根据类型获取对象
        Cat cat1 = context.getBean(Cat.class);
        Cat cat2 = context.getBean(Cat.class);
        Cat cat3 = context.getBean(Cat.class);
        cat1.hello();
        cat2.hello();
        cat3.hello();
        System.out.println(cat1);
        System.out.println(cat2);
        System.out.println(cat3);

        /**测试Bean的生命周期*/
        Snake snake = context.getBean(Snake.class);
        snake.eat();
    }
}
